import { Graph } from '@antv/x6'
import { CustomCircle } from './circle'
import { CustomEllipse } from './ellipse'
import { CustomLine } from './line'
import { CustomPath } from './path'
import { CustomPolygon } from './polygon'
import { CustomRect } from './rect'
// import { CustomElectric } from './electric'

const shape = {
  CustomCircle,
  CustomLine,
  CustomEllipse,
  CustomPath,
  CustomPolygon,
  CustomRect
}

// const line = () => null

// function registerEdge() {
//   Graph.registerMarker('none', line)
// }

// function unregisterEdge() {
//   Graph.unregisterMarker('none', line)
// }

function toLine(string) {
  return (string[0] + string.substr(1).replace(/([A-Z])/g, '-$1')).toLowerCase()
}

export function register() {
  // registerEdge()
  Object.keys(shape).forEach((key) => {
    Graph.registerNode(toLine(key), shape[key])
  })
}

export function unregister() {
  // unregisterEdge()
  Object.keys(shape).forEach((key) => {
    Graph.unregisterNode(toLine(key))
  })
}
